import React, { Component } from 'react'
import Tab from './component/tabcontrol'
export default class app extends Component {
    constructor(){
        super()
        this.state = {
            currentTitle:'流行',
            titles:['流行','说唱','经典']
        }
    }
    render() {
        const {currentTitle,titles} = this.state
        return (
            <div>
                <Tab list={titles} itemClick={index => this.itemClick(index)}></Tab>
                <h2>{currentTitle}</h2>
            </div>
        )
    }
    itemClick(index){
        console.log(index)
        const list = this.state.titles
        this.setState({
            currentTitle:list[index]
        })
    }
}
